{% extends '::layout.html.twig' %}

{% block title %}Tableau de bord{% endblock%}

{% block titreNav %}Tableau de bord{% endblock %}

{% block titreContent %}Etat d'avancement des User Stories{% endblock %}

{% block titreBreadcrumbs %}
<li><a href="#">Tableau de bord</a></li>
{% endblock %}

{% block contentnav %}
<div class="sideWidget">
    <form method="post" {{ form_enctype(form) }}>
        <div class="formRow">{{ form_row(form.refUserstorie) }}</div>
        {%if app.session.get('role') == "ROLE_SCRUMMASTER" or app.session.get('role') == "ROLE_DEV"%}
        <div class="formRow">{{ form_row(form.avancement) }}</div>
        {{ form_rest(form) }}
        {%endif%}
        <div class="formRow noBorderB">
            {%if app.session.get('role') == "ROLE_SCRUMMASTER" or app.session.get('role') == "ROLE_DEV"%}
                <input type="submit" class="buttonS bLightBlue" value="Modifier l'avancement">
            {%else%}
                <input type="submit" class="buttonS bLightBlue" value="Valider user story">
            {%endif%}
            </div>
        </form>
    </div>
{% endblock %}

{% block content %}


    {% if app.session.get('role') == "ROLE_SCRUMMASTER"%}


            <div class="wrapper">
                <div class="widget grid12">
                    <div class="whead"><h6>Scrum Board</h6><div class="clear"></div></div>

                    <table cellpadding="0" cellspacing="0" width="100%" class="tDefault">
                        <thead>
                            <tr>
                                <td>NON COMMENCE</td>
                                <td>EN COURS</td>
                                <td>A TESTER</td>
                                <td>VALIDE
                            </tr>
                        </thead>
                        <tbody>
                            {% for affectation in lastsprintaffect  %}
                            <tr>
                                <td>{% if affectation.refUserstorie.statut == 'Non commencé'%}{{ affectation.refUserstorie.role }}{% endif %}</td>
                                <td>{% if affectation.refUserstorie.statut == 'En cours'%}{{ affectation.refUserstorie.role }}{% endif %}</td>
                                <td>{% if affectation.refUserstorie.statut == 'Fini'%}{{ affectation.refUserstorie.role }}{% endif %}</td>
                                <td>{% if affectation.refUserstorie.statut == 'Validé'%}{{ affectation.refUserstorie.role }}{% endif %}</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="clear"></div>

            <div class="wrapper">
                <div class="widget grid12">
                    <div class="whead">
                        <h6>Sprint en cours</h6>
                        <div class="clear"></div>
                    </div>
                    <table class="dTable dataTable">
                        <thead>
                            <tr>
                                <th>User Story</th>
                                <th>Developpeur</th>
                                <th>Statut</th>
                                <th>Avancement (%)</th>
                            </tr>
                        </thead>
                        <tbody>
                    {% for affectation in lastsprintaffect  %}
                                <tr>
                                    <td class="center">{{ affectation.refUserstorie.role }}</td>
                                    <td class="center">{{ affectation.refUtilisateur.nom }}</td>
                                    <td class="center">{{ affectation.refUserstorie.statut }}</td>
                                    <td class="center">{{ affectation.avancement }}</td>
                                </tr>
                    {% endfor %}
                            </tbody>
                        </table>
                    </div>
                </div>
    {% endif %}
            
    <div class="wrapper">

    {% if app.session.get('role') == "ROLE_CLIENT" or app.session.get('role') == "ROLE_SCRUMMASTER"%}

        <div class="widget grid12">
            <div class="whead">
                <h6>Avancement general</h6>
                <div class="clear"></div>
            </div>
            <table class="dTable dataTable">
                <thead>
                    <tr>
                        <th>User Story</th>
                        <th>Projet</th>
                        <th>Statut</th>
                        <th>Avancement</th>
                    </tr>
                </thead>
                <tbody>
        {% for userstory in userstories  %}
                        <tr>
                            <td class="center">{{ userstory.role }}</td>
                            <td class="center">{{ userstory.refProjet.nom }}</td>
                            <td class="center">{{ userstory.statut }}</td>
                        {% set affect = false %}
                        {% for affectation in affectations  %}
                            {% if affectation.refUserstorie == userstory%}
                            <td class="center">{{ affectation.avancement }}</td>
                            {% set affect = true %}
                            {% endif %}
                        {% endfor %}
                        {% if affect == false%}
                            <td class="center">0</td>
                        {% endif %}
                        </tr>
         {% endfor %}
                    </tbody>
                </table>
            </div>

    {% elseif app.session.get('role') == "ROLE_DEV"%}
            <div class="widget grid12">
                <div class="whead">
                    <h6>Avancement general</h6>
                    <div class="clear"></div>
                </div>
                <table class="dTable dataTable">
                    <thead>
                        <tr>
                            <th>User Story</th>
                            <th>Sprint</th>
                            <th>Projet</th>
                            <th>Statut</th>
                            <th>Avancement (%)</th>
                        </tr>
                    </thead>
                    <tbody>
                    {% for affectation in affectations  %}
                            <tr>
                                <td class="center">{{ affectation.refUserstorie.role }}</td>
                                <td class="center">{{ affectation.refSprint.date.format('Y-m-d') }}</td>
                                <td class="center">{{ affectation.refUserstorie.refProjet.nom }}</td>
                                <td class="center">{{ affectation.refUserstorie.statut }}</td>
                                <td class="center">{{ affectation.avancement }}</td>
                            </tr>
                    {% endfor %}
                        </tbody>
                    </table>
                </div>
    {% endif %}
            </div>

{% endblock %}

